<!--定义局部的标识变量 novalidate是的当前的表单不适用浏览器默认的表单校验-->
<form #userform="ngForm" (ngSubmit)="onSubmit(userform)" novalidate>
      <div>用户名：<input  ngModel required minlength="6" type="text" name="username"></div>
      <div [hidden]="userform.form.get('username').valid || userform.form.get('username').untouched">
            <div [hidden]="!userform.hasError('required','username')">用户名不能为空</div>
            <div [hidden]="!userform.hasError('minlength','username')">用户名的长度至少为6位</div>
      </div>
      <div>手机号码：<input ngModel mobile type="text" name="telephone"></div>
      <div ngModelGroup="passwordsGroup" password>
          <div>密码：<input ngModel type="password" name="password"></div>
          <div>确认密码：<input ngModel type="password" name="repeatpassword"></div>
      </div>
      <div [hidden]="!userform.hasError('password','passwordsGroup')">
          {{ userform.form.getError('password','passwordsGroup')?.descxxx }}
        </div>
      <button type="submit">注册</button>
</form>